/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.suspend.remote;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.net.Uri;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import com.qihoo.gamecenter.sdk.suspend.b.b;
import java.io.InputStream;
import java.util.Date;

public class QSuspendView extends View {
    private static int c = 0;
    private static int d = 0;
    private static int e = 0;
    private static int f = 0;
    private Context g = null;
    private int h = 0;
    private int i = 0;
    private WindowManager j;
    private WindowManager.LayoutParams k;
    private String l = "";
    private long m = 0L;
    private long n = 0L;
    public static int a = 0;
    public static int b = 0;

    public QSuspendView(Context paramContext, WindowManager paramWindowManager,
            WindowManager.LayoutParams paramLayoutParams, String paramString) {
        super(paramContext);
        this.g = paramContext;
        this.j = paramWindowManager;
        this.k = paramLayoutParams;
        this.h = paramLayoutParams.width;
        this.i = paramLayoutParams.height;
        this.l = paramString;
    }

    protected void onDraw(Canvas paramCanvas) {
        try {
            super.onDraw(paramCanvas);
            int i1 = 3;
            InputStream localInputStream = null;
            if (!(TextUtils.isEmpty(this.l)))
                localInputStream = getResources().openRawResource(
                        getResources().getIdentifier(this.l, "drawable", this.g.getPackageName()));
            Bitmap localBitmap = BitmapFactory.decodeStream(localInputStream);
            a(paramCanvas, localBitmap, 0, i1, this.h, this.i, 0, 0);
            if (localInputStream == null)
                return;
            try {
                localInputStream.close();
                localInputStream = null;
            } catch (Exception localException2) {
                localException2.printStackTrace();
                b.a("QSuspendView", "ex: " + localException2.toString());
            }
        } catch (Exception localException1) {
            b.a("QSuspendView", localException1);
        } catch (Error localError) {
            b.a("QSuspendView", localError);
        }
    }

    public static void a(Canvas paramCanvas, Bitmap paramBitmap, int paramInt1, int paramInt2, int paramInt3,
            int paramInt4, int paramInt5, int paramInt6) {
        Rect localRect1 = new Rect();
        Rect localRect2 = new Rect();
        localRect2.left = paramInt1;
        localRect2.top = paramInt2;
        localRect2.right = (localRect2.left + paramInt3);
        localRect2.bottom = (localRect2.top + paramInt4);
        Paint localPaint = new Paint();
        localPaint.setAlpha(192);
        paramCanvas.drawBitmap(paramBitmap, null, localRect2, localPaint);
        localRect2 = null;
    }

    public boolean onTouchEvent(MotionEvent paramMotionEvent) {
        c = (int) paramMotionEvent.getRawX();
        d = (int) paramMotionEvent.getRawY() - 40;
        switch (paramMotionEvent.getAction()) {
        case 0:
            e = (int) paramMotionEvent.getX();
            f = (int) paramMotionEvent.getY();
            this.m = new Date().getTime();
            break;
        case 2:
            a(this);
            break;
        case 1:
            a(this);
            int[] arrayOfInt = new int[2];
            getLocationOnScreen(arrayOfInt);
            if (a == 0)
                a = arrayOfInt[0];
            if (b == 0)
                b = arrayOfInt[1];
            this.n = new Date().getTime();
            b.a("QSuspendView", "diffTime: " + (this.n - this.m));
            b.a("QSuspendView", "abs(x): " + Math.abs(arrayOfInt[0] - a));
            b.a("QSuspendView", "abs(y): " + Math.abs(arrayOfInt[1] - b));
            if ((this.n - this.m < 800L) && (Math.abs(arrayOfInt[0] - a) < 10) && (Math.abs(arrayOfInt[1] - b) < 40)) {
                this.m = 0L;
                this.n = 0L;
                Uri localUri = Uri.parse("http://www.so.com");
                Intent localIntent = new Intent("android.intent.action.VIEW", localUri);
                localIntent.addFlags(268435456);
                this.g.startActivity(localIntent);
            }
            a = arrayOfInt[0];
            b = arrayOfInt[1];
        }
        return super.onTouchEvent(paramMotionEvent);
    }

    private void a(View paramView) {
        this.k.x = (c - e);
        this.k.y = (d - f);
        this.j.updateViewLayout(paramView, this.k);
    }
}